/**
 * Copyright 2008 Wink Saville
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* Only one allowed */
if (typeof McConst == "undefined")
{
    McConst = new Object();
    McConst.CMD_NEEDS_REPLY = 0x01;
    McConst.CMD_REPLY = 0x02;
    McConst.MC_GUID = -1;
    
    McConst.mkCmd = function (v) { return (v << 4); }
    McConst.mkRequest = function (v) { return McConst.mkCmd(v) | McConst.CMD_NEEDS_REPLY; }
    McConst.mkReply = function (v) { return McConst.mkCmd(v) | McConst.CMD_REPLY; }
    
    McConst.MC_CMD_NOP = McConst.mkCmd(0);
    McConst.MC_CMD_STARTED = McConst.mkCmd(1);
    McConst.MC_CMD_ECHO = McConst.mkRequest(2);
        
    McConst.MCMGR_CMD_GET_SECONDARY_PORT = McConst.mkRequest(3);
    McConst.MCMGR_CMD_REGISTER_MC = McConst.mkRequest(4);
    McConst.MCMGR_CMD_LOOKUP_MC = McConst.mkRequest(5);
    McConst.MCMGR_CMD_GET_SESSION_ID_SET = McConst.mkRequest(6);
    
    McConst.MCMASTER_GUID = -2;
    McConst.MCMASTER_CMD_REGISTER_DEV = McConst.mkRequest(1);
    McConst.MCMASTER_CMD_LOOKUP_DEV = McConst.mkRequest(2);
    McConst.MCMASTER_CMD_FORWARD_MSG = McConst.mkCmd(3);
    
    McConst.MCPIPE_GUID = -3;
    McConst.MCPIPE_CMD_CONNECTED = McConst.mkCmd(1);
    McConst.MCPIPE_CMD_CLOSED = McConst.mkCmd(2);
    McConst.MCPIPE_CMD_PRODUCER_MSG = McConst.mkCmd(3);
    McConst.MCPIPE_CMD_PRODUCER_HTTP_HEADER_MSG = McConst.mkCmd(4);
    McConst.MCPIPE_CMD_PRODUCER_HTTP_GET_MSG = McConst.mkCmd(5);
    
    /*
     * Well known status values
     */
    McConst.STATUS_OK = 0;
    McConst.STATUS_ERR = 1;
    McConst.STATUS_UNKNOWN_CMD = 2;
    McConst.STATUS_ECHO = 3;
    
    /*
     * A bit used for some debugging, TestHmcServer.java
     * it modifies the command to be "noisy" and output additional debug
     */
    McConst.NOISY = 0x80000;
}
